package CelestialDataStructures;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.text.ParseException;

public class DateFormat {
    
    private static final SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
    public static final SimpleDateFormat ydf = new SimpleDateFormat("yyyy");
    public static final SimpleDateFormat mdf = new SimpleDateFormat("M");
    public static final SimpleDateFormat ddf = new SimpleDateFormat("d");

    public static String format(Date d){
        return sdf.format(d);
    }
    /*************************************************************************/
    public static String formatLong(Date d){
        return new SimpleDateFormat("MMMM dd, yyyy").format(d);
    }
    /*************************************************************************/
    public static String month(Date d){
        return mdf.format(d);
    }
    /*************************************************************************/
    public static String year(Date d){
        return ydf.format(d);
    }
    /*************************************************************************/
    public static String day(Date d){
        return ddf.format(d);
    }
    /*************************************************************************/
    public static Date parse(String d) throws ParseException{
        sdf.setLenient(false);
        return sdf.parse(d);
    }
    /*************************************************************************/
    public static void main(String[] args){

        Date d = new Date();
        System.out.println(DateFormat.formatLong(d));
    }
}
